package com.sch.hospital.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.CrossOrigin;
import com.sch.hospital.domain.Result;
import com.sch.hospital.domain.Award;
import com.sch.hospital.service.IAwardService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 医院荣誉Controller
 * 
 * @author ruoyi
 * @date 2025-06-30
 */
@Tag(name = "医院荣誉相关接口")
@RestController
@RequestMapping("/system/award")
@CrossOrigin
public class AwardController
{
    @Autowired
    private IAwardService awardService;

    /**
     * 查询医院荣誉列表
     */
    @Operation(summary = "查询医院荣誉列表")
    @GetMapping("/list")
    public Result list(Award award)
    {
        List<Award> list = awardService.selectAwardList(award);
        return Result.success(list);
    }

    /**
     * 获取医院荣誉详细信息
     */
    @Operation(summary = "获取医院荣誉详细信息")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.success(awardService.selectAwardById(id));
    }

    /**
     * 新增医院荣誉
     */
    @Operation(summary = "新增医院荣誉")
    @PostMapping
    public Result add(@RequestBody Award award)
    {
        int rows = awardService.insertAward(award);
        return rows > 0 ? Result.success() : Result.error("新增医院荣誉失败");
    }

    /**
     * 修改医院荣誉
     */
    @Operation(summary = "修改医院荣誉")
    @PutMapping
    public Result edit(@RequestBody Award award)
    {
        int rows = awardService.updateAward(award);
        return rows > 0 ? Result.success() : Result.error("修改医院荣誉失败");
    }

    /**
     * 删除医院荣誉
     */
	@Operation(summary = "删除医院荣誉")
    @DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        int rows = awardService.deleteAwardByIds(ids);
        return rows > 0 ? Result.success() : Result.error("删除医院荣誉失败");
    }
}
